/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = frct_mng.h                                         */
/*  NOTE      = conntrack管理                                      */
/*  DATE      = 2014/10/11                                         */
/*******************************************************************/

#ifndef __FRCT_MNG_H_
#define __FRCT_MNG_H_

#define FRCT_LOCK(x)   pthread_spin_lock(&(x->lock))
#define FRCT_UNLOCK(x) pthread_spin_unlock(&(x->lock))

extern unsigned long g_ul_pcap_queue_used;

int frct_init(unsigned int ui_table_size);

void frct_destroy(void);

Conntrack *frct_add(char *p_src_mac, char *p_dst_mac
                    , u_short us_proto, u_int ui_src, u_short us_sport, u_int ui_dest, u_short us_dport
                    , int i_flag_insert_task, Franalyz_cmd em_analyz_cmd
                    , int i_flag_get_ct, int i_status
                    , char *p_data, unsigned int ui_data_len, struct timeval st_timeval_pkg);
void frct_del(u_short us_proto, u_int ui_src, u_short us_sport, u_int ui_dest, u_short us_dport, struct timeval st_timeval_pkg);

void frcap_node_free(Frlist_node *node);

void frct_del_disable(void);
void frct_del_enable(void);

Conntrack *frct_get(u_short us_proto, u_int ui_src, u_short us_sport, u_int ui_dest, u_short us_dport);
void frct_put(Conntrack *p_st_ct);

Frlist_node *frct_l7proto_node_mk(L7_module *p_st_l7_module);
int  frct_l7proto_is_first(Conntrack *p_st_ct);
int  frct_l7proto_is_last(Conntrack *p_st_ct);
int frct_l7proto_is_last2(Conntrack *p_st_ct, unsigned int ui_l7proto_idx);
void frct_l7proto_node_show(Frlist_node *p_st_node, char *p_outbuff, unsigned int ui_buff_size);
void frct_l7proto_node_free(Frlist_node *p_st_node);

char *frct_status(uint16_t ui_flg_status);
char *frct_l7status(uint16_t ui_flg_status);

#endif
